import { IconCopy } from '@codexteam/icons';
class CopyBlockTune {
    // 指定当前组件的类型为Tune模式
    static get isTune() {
        return true;
    }

    constructor({api, data, config, block}) {
        this.api = api;
        this.block = block;
    }

    render() {
        return {
          icon: IconCopy,
          label: '复制',
          onActivate: async () => {
            // 复制逻辑
            const curIdx = this.api.blocks.getCurrentBlockIndex();
            const { name } = this.block;
            const { data } = await this.block.save();
            this.api.blocks.insert(name, {...data}, undefined, curIdx + 1, true);
          }
        };
    }

    save() {
        return {
          prop: 'value'
        };
    }

    wrap(blockContent) {
        const myWrapper = document.createElement('div');
    
        myWrapper.append(blockContent);
    
        myWrapper.style.fontSize = '0.9em';
    
        return myWrapper;
    }
}

export default CopyBlockTune